<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.tjtt.tdm.system.action.MenuAction"%>
<%@ page import="com.tjtt.tdm.system.bean.Users" %>
	<%
		Users common_u = (Users)session.getAttribute("TDM_USER");
		Long common_userid = common_u.getUserid();
		String common_username = common_u.getUsername();
	%>
<%
	String common_contextPath = request.getContextPath();
	String common_basePath = request.getScheme() + "://"
		+ request.getServerName() + ":" + request.getServerPort()
			+ common_contextPath + "/";
    String pageNumber= session.getAttribute("SYS_PAGECOUNT").toString();
    String buttonids = MenuAction.getRoleModulebutton(request);
%>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jqGrid/themes/smoothness/jquery-ui-1.7.2.custom.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jqGrid/css/jqgrid.css" />

<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/jquery.jqGrid.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/grid.setcolumns.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/jquery.tablednd.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/jquery.form.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/grid.locale-cn.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jqGrid/js/jquery.ui.datepicker-zh-CN.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/mypage.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/checkbutton.js"></script>
<style>
<!--
body{font-family:Arial;font-size:12px;margin:0 auto;}
-->
</style>
<script type="text/javascript" language="javaScript">
	var common_contextPath="<%=common_contextPath%>";
	var common_basePath="<%=common_basePath%>";
	var pageNumber="<%=pageNumber%>";
	var common_userid="<%=common_userid%>";
	var common_username="<%=common_username%>";
	 $(document).ready(function(){
		 checkbutton('<%=buttonids%>');
	 });
	/**
 **************************************************调整页面时 列表大小跟着变动 begin
 */
 /*
var t=document.documentElement.clientWidth;  
window.onresize = function(){  
	if(t != document.documentElement.clientWidth){
		t = document.documentElement.clientWidth; 
		//doResize(); 
	}
} */

/**
 *
 * @param {Function} callback 回调函数
 * @param {Integer} delay   延迟时间，单位为毫秒(ms)，默认150
 * @param {Object} context  上下文，即this关键字指向的对象，默认为null
 * @return {Function}
 */
function debounce(callback, delay, context){
	   if (typeof(callback) !== "function") {
	        return;
	    } 
	    delay = delay || 150;
	    context = context || null;
	    var timeout;
	    var runIt = function(){  callback.apply(context);  };
	   return (function(){
	        window.clearTimeout(timeout);
	        timeout = window.setTimeout(runIt, delay);
	    });
}
var winResizeHandler = function(event){
	 $("#gridTable").setGridWidth($(window).width()-10);
};

window.onresize= debounce(winResizeHandler, 300);



//取得页面大小
function getPageSize() { 
//http://www.blabla.cn/js_kb/javascript_pagesize_windowsize_scrollbar.html 
	var winW, winH; 
	if(window.innerHeight) {// all except IE 
		winW = window.innerWidth; 
		winH = window.innerHeight; 
	} else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 Strict Mode 
		winW = document.documentElement.clientWidth; 
		winH = document.documentElement.clientHeight; 
	} else if (document.body) { // other 
		winW = document.body.clientWidth; 
		winH = document.body.clientHeight; 
	}  // for small pages with total size less then the viewport  
	return {WinW:winW, WinH:winH}; 
} 

function countlen(textarea){
	    if (textarea.value.length> 250){ 
	        alert("最多为250个字符,字符输入超出限制!") 
	        textarea.value=textarea.value.substring(0,250) 
	    }	
	    return   true 
	}
	
	function RepNumber(obj) {
		var reg = /^[\d]+$/g;
		if (!reg.test(obj.value)) {
		var txt = obj.value;
		txt.replace(/[^0-9]+/, function (char, index, val) {//匹配第一次非数字字符
		obj.value = val.replace(/\D/g, "");//将非数字字符替换成""
		var rtextRange = null;
		if (obj.setSelectionRange) {
		obj.setSelectionRange(index, index);
		} else {//支持ie
		rtextRange = obj.createTextRange();
		rtextRange.moveStart('character', index);
		rtextRange.collapse(true);
		rtextRange.select();
		}
		})
		}
		} 
		
		function checkNum(inputData){
		var sNumber;
	    sNumber=Number(inputData);
	    if (isNaN(inputData)){
	       return false;
	     }
	    return true;
	}
	
	  //选择部门
	function selectdept(id)
	{
		var datas = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/choose_organizationIndex.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("dept_"+id).value = json1.ORG_NAME;
			 document.getElementById(id).value = json1.ORG_ID;
		}
	}
</script>